import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {GoodsVO, GoodsForm, GoodsQuery} from '@/api/business/goods/types';

/**
 * 查询任务列表
 * @param query
 * @returns {*}
 */

export const listGoods = (query?: GoodsQuery): AxiosPromise<GoodsVO[]> => {
  return request({
    url: '/business/goods/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询任务详细
 * @param goodsId
 */
export const getGoods = (goodsId: string | number): AxiosPromise<GoodsVO> => {
  return request({
    url: '/business/goods/' + goodsId,
    method: 'get'
  });
};

/**
 * 新增任务
 * @param data
 */
export const addGoods = (data: GoodsForm) => {
  return request({
    url: '/business/goods',
    method: 'post',
    data: data
  });
};

/**
 * 修改任务
 * @param data
 */
export const updateGoods = (data: GoodsForm) => {
  return request({
    url: '/business/goods',
    method: 'put',
    data: data
  });
};

/**
 * 修改任务状态
 * @param data
 */
export const updateGoodsStatus = (params: any) => {
  return request({
    url: '/business/goods/updateGoodsStatus',
    method: 'put',
    params: params
  });
};


/**
 * 强制下架
 * */
export const forceShelve = (goodsId: string | number): AxiosPromise<GoodsVO> => {
  return request({
    url: '/business/goods/forceShelve/' + goodsId,
    method: 'get'
  });
};



/**
 * 删除任务
 * @param goodsId
 */
export const delGoods = (goodsId: string | number | Array<string | number>) => {
  return request({
    url: '/business/goods/' + goodsId,
    method: 'delete'
  });

};
